package com.fire.control.system.support.util;

import java.util.ArrayList;
import java.util.List;

import com.fire.control.system.entity.Company;
import com.fire.control.system.entity.Resource;
import com.fire.control.system.entity.Role;
import com.fire.control.system.statics.Type_Resource;

public class InitSystemUtil {
	
	
	public final static List<Resource> getInitAllResources(){
		List<Resource> result = new ArrayList<Resource>();
		Resource rootResource = new Resource();
		rootResource.setName("root");
		rootResource.setResourceCode(BusinessStaticValue.resource_root_code);
		rootResource.setResourceDesc("root");
		//rootResource.setResourceType(Type_Resource.menu_open);
		result.add(rootResource);
		result.addAll(getInitHomePageResouce());
		result.addAll(getInitDeviceManagementResouce());
		result.addAll(getInitDeviceWarningResouce());
		return result;
	}
	
	public final static List<Resource> getInitHomePageResouce(){
		List<Resource> result = new ArrayList<Resource>();
		
		Resource homePage = new Resource();
		homePage.setName("首页");
		homePage.setResourceCode(BusinessStaticValue.resource_root_code+1);
		homePage.setResourceDesc("首页展开菜单");
		//homePage.setResourceType(Type_Resource.menu_open);
		result.add(homePage);
		
		Resource monitorMap = new Resource();
		monitorMap.setName("地图监控");
		monitorMap.setResourceCode(homePage.getResourceCode()+"000"+1);
		monitorMap.setResourceDesc("首页-地图监控");
		//monitorMap.setResourceType(Type_Resource.menu_url);
		monitorMap.setResourceUrl("/homePage/monitor/map");
		//monitorMap.setActionUrl("?");
		result.add(monitorMap);
		
		Resource neglect = new Resource();
		neglect.setName("误报忽略");
		neglect.setResourceCode(monitorMap.getResourceCode()+"000"+1);
		neglect.setResourceDesc("首页-地图监控-误报忽略");
		//neglect.setResourceType(Type_Resource.button_submit);
		//neglect.setActionUrl("?");
		result.add(neglect);
		
		Resource maintenance = new Resource();
		maintenance.setName("维保");
		maintenance.setResourceCode(monitorMap.getResourceCode()+"000"+2);
		maintenance.setResourceDesc("首页-地图监控-维保");
		//maintenance.setResourceType(Type_Resource.button_url);
		maintenance.setResourceUrl("?");
		result.add(maintenance);
		
		Resource messagePush = new Resource();
		messagePush.setName("报警推送");
		messagePush.setResourceCode(monitorMap.getResourceCode()+"000"+3);
		messagePush.setResourceDesc("首页-地图监控-报警推送");
		//messagePush.setResourceType(Type_Resource.button_submit);
		//messagePush.setActionUrl("?");
		result.add(messagePush);
		return result;
	}
	
	public final static List<Resource> getInitDeviceManagementResouce(){
		List<Resource> result = new ArrayList<Resource>();
		
		Resource deviceManagement = new Resource();
		deviceManagement.setName("设备管理");
		deviceManagement.setResourceCode(BusinessStaticValue.resource_root_code+2);
		deviceManagement.setResourceDesc("设备管理-展开菜单");
		//.setResourceType(Type_Resource.menu_open);
		result.add(deviceManagement);
		
		Resource deviceList = new Resource();
		deviceList.setName("设备列表");
		deviceList.setResourceCode(deviceManagement.getResourceCode()+"000"+1);
		deviceList.setResourceDesc("设备管理-设备列表");
		//deviceList.setResourceType(Type_Resource.menu_url);
		deviceList.setResourceUrl("/device/device/list");
		//deviceList.setActionUrl("?");
		result.add(deviceList);
		
		Resource addDevice = new Resource();
		addDevice.setName("添加设备");
		addDevice.setResourceCode(deviceList.getResourceCode()+"000"+1);
		addDevice.setResourceDesc("设备管理-设备列表-添加设备");
		//addDevice.setResourceType(Type_Resource.menu_url);
		//addDevice.setActionUrl("?");
		result.add(addDevice);
		
		Resource deviceGroupList = new Resource();
		deviceList.setName("设备组列表");
		deviceList.setResourceCode(deviceManagement.getResourceCode()+"000"+2);
		deviceList.setResourceDesc("设备管理-设备组列表");
		//deviceList.setResourceType(Type_Resource.menu_url);
		deviceList.setResourceUrl("/device/deviceGroup/list");
		//deviceList.setActionUrl("?");
		result.add(deviceGroupList);
		
		Resource addDeviceGroup = new Resource();
		addDeviceGroup.setName("添加设备组");
		addDeviceGroup.setResourceCode(deviceGroupList.getResourceCode()+"000"+1);
		addDeviceGroup.setResourceDesc("设备管理-设备组列表-添加设备组");
		//addDeviceGroup.setResourceType(Type_Resource.menu_url);
		//addDeviceGroup.setActionUrl("?");
		result.add(addDeviceGroup);
		
		Resource deviceMaintenceList = new Resource();
		deviceMaintenceList.setName("设备列表");
		deviceMaintenceList.setResourceCode(deviceManagement.getResourceCode()+"000"+3);
		deviceMaintenceList.setResourceDesc("设备管理-维保设备列表");
		//deviceMaintenceList.setResourceType(Type_Resource.menu_url);
		deviceMaintenceList.setResourceUrl("/device/Maintence/list");
		//deviceMaintenceList.setActionUrl("?");
		result.add(deviceMaintenceList);
		
		Resource deviceMaintence = new Resource();
		deviceMaintence.setName("维保处理");
		deviceMaintence.setResourceCode(deviceMaintenceList.getResourceCode()+"000"+1);
		deviceMaintence.setResourceDesc("设备管理-维保设备列表-维保处理");
		//deviceMaintence.setResourceType(Type_Resource.menu_url);
		//deviceMaintence.setActionUrl("?");
		result.add(deviceMaintence);
		
		return result;
	}
	
	public final static List<Resource> getInitDeviceWarningResouce(){
		List<Resource> result = new ArrayList<Resource>();
		
		Resource warningManagement = new Resource();
		warningManagement.setName("报警管理");
		warningManagement.setResourceCode(BusinessStaticValue.resource_root_code+3);
		warningManagement.setResourceDesc("报警管理-展开菜单");
		//warningManagement.setResourceType(Type_Resource.menu_open);
		result.add(warningManagement);
		
		Resource warningList = new Resource();
		warningList.setName("报警列表");
		warningList.setResourceCode(warningManagement.getResourceCode()+"000"+1);
		warningList.setResourceDesc("报警管理-报警列表");
		//warningList.setResourceType(Type_Resource.menu_url);
		warningList.setResourceUrl("/warning/warning/list");
		//warningList.setActionUrl("?");
		result.add(warningList);
		
		Resource unsolvedWarningList = new Resource();
		unsolvedWarningList.setName("待处理列表");
		unsolvedWarningList.setResourceCode(warningManagement.getResourceCode()+"000"+2);
		unsolvedWarningList.setResourceDesc("报警管理-待处理列表");
		//unsolvedWarningList.setResourceType(Type_Resource.menu_url);
		unsolvedWarningList.setResourceUrl("/warning/unsolvedWarning/list");
		//unsolvedWarningList.setActionUrl("?");
		result.add(unsolvedWarningList);
		
		Resource warningMode = new Resource();
		warningMode.setName("报警模式设置");
		warningMode.setResourceCode(warningManagement.getResourceCode()+"000"+3);
		warningMode.setResourceDesc("报警管理-报警模式设置");
		//warningMode.setResourceType(Type_Resource.menu_url);
		warningMode.setResourceUrl("/warning/warningMode/set");
		//warningMode.setActionUrl("?");
		result.add(warningMode);
		
		Resource addWarningMode = new Resource();
		addWarningMode.setName("添加");
		addWarningMode.setResourceCode(warningMode.getResourceCode()+"000"+1);
		addWarningMode.setResourceDesc("报警管理-报警模式设置-添加");
		//addWarningMode.setResourceType(Type_Resource.menu_url);
		//addWarningMode.setActionUrl("?");
		result.add(addWarningMode);
		
		Resource warningPush = new Resource();
		warningPush.setName("报警推送设置");
		warningPush.setResourceCode(warningManagement.getResourceCode()+"000"+4);
		warningPush.setResourceDesc("报警管理-报警推送设置");
		//warningPush.setResourceType(Type_Resource.menu_url);
		warningPush.setResourceUrl("/warning/warningPush/set");
		//warningPush.setActionUrl("?");
		result.add(warningPush);
		
		Resource addWarningPush = new Resource();
		addWarningPush.setName("添加");
		addWarningPush.setResourceCode(warningPush.getResourceCode()+"000"+1);
		addWarningPush.setResourceDesc("报警管理-报警推送设置-添加");
		//addWarningPush.setResourceType(Type_Resource.menu_url);
		//addWarningPush.setActionUrl("?");
		result.add(addWarningPush);
		
		return result;
	}
	
	public static final Company getInitSuperCompany(List<Role> roles){
		
		Company superCompany = new Company();
		superCompany.setAddress("公司地址");
		//superCompany.setCompanyCode(BusinessStaticValue.company_root_code);
		superCompany.setCompanyName("公司名称");
		superCompany.setContact("公司联系人");
		superCompany.setEmail("公司邮箱");
		//superCompany.setLoginName(BusinessStaticValue.init_system_loginName);
		//superCompany.setPassword(XdaoPassword.getXdaoPassword(BusinessStaticValue.init_system_loginName,
		//		BusinessStaticValue.init_system_password));
		superCompany.setTelNumber("联系电话");
		//superCompany.setRoles(roles);
		
		return superCompany;
		
	}
	
	public static final Role getInitSuperRole(List<Resource> resources){
		Role superRole = new Role();
		superRole.setId(BusinessStaticValue.init_role_id);
		superRole.setCompany(null);
		superRole.setResources(resources);
		superRole.setRoleName("super role");
		return superRole;
	}
}
